'use strict';
 const db=uniCloud.database()
 const $ = db.command.aggregate
exports.main = async (event, context) => {
	const {
		user_id
	} = event
	
	let userinfo = await db.collection('user').doc(user_id).get()
	userinfo = userinfo.data[0]
	
	const list = await db.collection("article")
	.aggregate()
	.addFields({//查找并添加数据
		is_like:$.in(['$_id',userinfo.article_likes_ids])
	})
	.project({
		content:0
	})
	.match({//过滤符合的条件
		is_like:true //过滤条件
	})
	.end()
	//返回数据给客户端
	return {
		code:200,
		message:"更新成功",
		data:list.data
	}
};
